//js文件引入外部js文件
//document.write('<script language="javascript" src="/js/import.js"></script>');
/*
 *	2015/11/25 星期三
 *	js 基础类编写（底层类）
 *  Hyang 处理文档数据管理类
 *
 *	Helper 协助处理类-非数据（Ajax）。js前端控制
 */
var Hyang =
{
	//jQuery $.post()方法用于 获取后台ajax返回数据=>Jquery扩展方法
	//Boolean 是否启动调试窗口
	ajaxReturn: function(url,json,Boolean)
	{
		if('' == url) return;
		if('' == json) json = {};
		var getdata = $.post(url,json,
			function(data){
				if(Boolean) alert(data);
				else return data;	
		});
		if(getdata) return getdata;
	},
		//分页函数		2015/12/4
	/*
	 *	format 格式：FE(<< < □ > >>),FC(首页 上一页 ■ 下一页 尾页),NE(<- p1 p2 p3……p8 p9 p10 ->),NC(上一页 p1 p2 p3……p8 p9 p10 下一页)
	 *	option 扩展字符 : json =>	option = {curPage:"select",}
	 *	"curPage":"select" 下拉框跳转和显示分页
	 *	onClick="PageClick()"   jQuery绑定事件失效，换此绑定法
	 */
	//setPage : function(curPage,numPage,format,option={curPage:''})		浏览器兼容性 去格式 option={curPage:''}//	2016/1/24
	setPage : function(curPage,numPage,format,option)
	{
		var html = '';
		var i = 0;
		var fmt = ((format)? format : 'NC');
		option = (this.empty(option)? {curPage:''} : option);//2016/1/24
		if(fmt.charAt(0) == 'N')
		{
			if(numPage<11)
			{
				for(i=1;i<=numPage;i++)
				{
					(i == curPage)? html += '<button type="button" class="pageBtn" id="curPage" onClick="PageClick('+i+')">'+i+'</button>' : html += '<button type="button" class="pageBtn" onClick="PageClick('+i+')">'+i+'</button>';
				}
			}
			else
			{
				if(curPage<11)
				{
					for(i=1;i<11;i++)
					{
						(i == curPage)? html += '<button type="button" class="pageBtn" id="curPage" onClick="PageClick('+i+')">'+i+'</button>' : html += '<button type="button" class="pageBtn" onClick="PageClick('+i+')">'+i+'</button>';
						if(fmt == 'NC')	(i== 10)? html += '<button type="button" class="pageBtn" id="nextPage">下一页</button>' : '';
						if(fmt == 'NE') (i== 10)? html += '<button type="button" class="pageBtn" id="nextPage"> > </button>' : '';
					}
				}
				else
				{
					if((curPage+10) < numPage)
					{
						for(i=curPage; i<=(curPage+10);i++)
						{
						if(fmt == 'NC')	(i==curPage)? html += '<button type="button" class="pageBtn" id="lastPage">上一页</button>' : '';
						if(fmt == 'NE') (i==curPage)? html += '<button type="button" class="pageBtn" id="lastPage"> < </button>' : '';
						(i == curPage)? html += '<button type="button" class="pageBtn" id="curPage'+i+'">'+i+'</button>' : html += '<button type="button" class="pageBtn" id="page'+i+'">'+i+'</button>';
						if(fmt == 'NC')	(i==(curPage+10))? html += '<button type="button" class="pageBtn" id="nextPage">下一页</button>' : '';
						if(fmt == 'NE') (i==(curPage+10))? html += '<button type="button" class="pageBtn" id="nextPage"> > </button>' : '';
						}
					}
					else
					{
						for(i=curPage;i<=numPage;i++)
						{
							if(fmt == 'NC')	(i == curPage)? html += '<button type="button" class="pageBtn" id="lastPage">上一页</button>' : '';
							if(fmt == 'NE') (i == curPage)? html += '<button type="button" class="pageBtn" id="lastPage"> < </button>' : '';
							(i == curPage)? html += '<button type="button" class="pageBtn" id="curPage'+i+'">'+i+'</button>' : html += '<button type="button" class="pageBtn" id="page'+i+'">'+i+'</button>';
						}
					}
				}
			}
			/*for(i=1,numPage<11;i<=numPage;i++)
			{
				(i == curPage)? html += '<button type="button" class="pageBtn" id="curPage'+i+'">'+i+'</button>' : html += '<button type="button" class="pageBtn" id="page'+i+'">'+i+'</button>';
			}
			for(curPage>10,i=curPage;i<(curPage+11),(curPage+10)<numPage;i++)
			{
				if(fmt == 'NC')	(i==curPage)? html += '<button type="button" class="pageBtn" id="lastPage">上一页</button>' : '';
				if(fmt == 'NE') (i==curPage)? html += '<button type="button" class="pageBtn" id="lastPage"> < </button>' : '';
				html += ((i == curPage)? '<button type="button" class="pageBtn" id="curPage'+i+'">'+i+'</button>' : '<button type="button" class="pageBtn" id="page'+i+'">'+i+'</button>');
				if(fmt == 'NC')	(i==(curPage+10))? html += '<button type="button" class="pageBtn" id="nextPage">下一页</button>' : '';
				if(fmt == 'NE') (i==(curPage+10))? html += '<button type="button" class="pageBtn" id="nextPage"> > </button>' : '';
			}
			for(i=curPage,curPage>10;i<numPage,(curPage+10)>numPage;i++)
			{
				if(fmt == 'NC')	(i == curPage)? html += '<button type="button" class="pageBtn" id="lastPage">上一页</button>' : '';
				if(fmt == 'NE') (i == curPage)? html += '<button type="button" class="pageBtn" id="lastPage"> < </button>' : '';
				(i == curPage)? html += '<button type="button" class="pageBtn" id="curPage'+i+'">'+i+'</button>' : html += '<button type="button" class="pageBtn" id="page'+i+'">'+i+'</button>';
				
			}
			*/
			return html;
			
		}
		else if(fmt.charAt(0) == 'F')
		{
			if(curPage > 2)
			{
				(fmt == 'FC')? html += '<button type="button" class="PageBtn" id="homePage">首页</button>' :  '';
				(fmt == 'FE')? html += '<button type="button" class="PageBtn" id="homePage"> << </button>' :  '';
			}
			if(curPage > 1)
			{
				(fmt == 'FC')?  html += '<button type="button" class="PageBtn" id="lastPage">上一页</button>' : '' ;
				(fmt == 'FE')?  html += '<button type="button" class="PageBtn" id="lastPage"> < </button>' : '' ;
			}
			//option = {curPage:"select",}
			if(option.curPage == "select")
			{
				html += '<select name="curPage">';
				for(i=1; i<=numPage; i++)
				//for(i=numPage; i<= 1; i--)
				{
					(i != curPage) ?  html +='<option value="'+i+'">'+i : html +='<option value="'+i+'" selected>'+i;
					//html +='<option value="'+i+'">'+i;
				}
				html += '</select>';
			}
			else
			{			
				html += '<button type="button" class="PageBtn" id="curPage">'+curPage+'</button>';
			}
			if(curPage < numPage)
			{
				(fmt == 'FC')?  html += '<button type="button" class="PageBtn" id="nextPage">下一页</button>' : '' ;
				(fmt == 'FE')?  html += '<button type="button" class="PageBtn" id="nextPage"> > </button>' : '' ; 
			}
			if((curPage+1) < numPage)
			{
				(fmt == 'FC')? html += '<button type="button" class="PageBtn" id="homePage">尾页</button>' :  '';
				(fmt == 'FE')? html += '<button type="button" class="PageBtn" id="homePage"> >> </button>' :  '';
			}
			return html;
		}
		else return false;
	},
	/*
	 *	分页显示	2016/2/24	增强setPage : function(curPage,numPage,format,option)方法,直接与 php Function/getData()对接
	 *	@param：*page 当前页，num 数据总数量，pNum 每页打印的数据条，pClass 分页条class，format 分页格式
	 */
	page:function(page,num,pNum,pClass,format)
	{
		if(this.empty(page))
			return;
		pNum = (this.empty(pNum)? 30:pNum);
		pClass = (this.empty(pClass)? "pageBar":pClass);
		//var numPage = Math.floor(num/pNum);
		var numPage = Math.ceil(num/pNum);
		var xhtml = '<p id="'+pClass+'" _max="'+numPage+'">';
		xhtml += this.setPage(page,numPage,format)+'</p>';
		return xhtml;
	},
		//随机颜色
	randColor : function(option)
	{
		return '#'+('00000'+(Math.random()*0x1000000<<0).toString(16)).slice(-6);
	},
		//数组函数-获取随机颜色
	randColArr: function()
	{
		//var colors = new Array("AntiqueWhite","Beige","Brown","Chocolate","Cyan","DarkGoldenRod","DarkOrange","DarkSlateGray","DeepSkyBlue","DimGray","Linen","Maroon","MintCream","Moccasin","Navy","Olive","PaleGreen","SeaGreen","Silver","Snow","SpringGreen","Tan","Wheat","aqua","aquamarine","azure","bisque","black","blanchedalmond","blue","blueviolet","burlywood","cadetblue","chartreuse");
		var colors = new Array("AliceBlue","AntiqueWhite","AquaMarine","Azure","Beige","Bisque","Black","BlanchedAlmond","Blue","BlueViolet","Brown","BurlyWood","CadetBlue","ChartReuse","Chocolate","Coral","CornFlowerBlue","CornSilk","Crimson","Cyan","DarkBlue","DarkCyan","DarkGoldenRod","DarkGray","DarkGreen","DarkKhaki","DarkMagenta","DarkOliveGreen","DarkOrange","DarkOrchid","DarkRed","DarkSalmon","DarkSeaGreen","DarkSlateBlue","DarkSlateGray","DarkTurquoise","DarkViolet","DeepPink","DeepSkyBlue","DimGray","DodgerBlue","FireBrick","FloralWhite","ForestGreen","GainsBoro","GhostWhite","Gold","GoldenRod","Gray","Green","GreenYellow","HoneyDew","HotPink","IndianRed","Indigo","Ivory","Khaki","Lavender","LavenderBlush","LawnGreen","LemonChiffon","LightBlue","LightCoral","LightCyan","LightGoldenRodYellow","LightGray","LightGreen","LightPink","LightSalmon","LightSeaGreen","LightSkyBlue","LightSlateGray","LightSteelBlue","LightYellow","Lime","LimeGreen","Linen","Magenta","Maroon","MediumAquaMarine","MediumBlue","MediumOrchid","MediumPurple","MediumSeaGreen","MediumSlateBlue","MediumSpringGreen","MediumTurquoise","MediumVioletRed","MidNightBlue","MintCream","MistyRose","Moccasin","NavajoWhite","Navy","OldLace","Olive","OliveDrab","Orange","OrangeRed","Orchid","PaleGoldenRod","PaleGreen","PaleTurquoise","PaleVioletRed","PapayaWhip","PeachPuff","Peru","Pink","Plum","PowderBlue","Purple","Red","RosyBrown","RoyalBlue","SaddleBrown","Salmon","SandyBrown","SeaGreen","SeaShell","Sienna","Silver","SkyBlue","SlateBlue","SlateGray","Snow","SpringGreen","SteelBlue","Tan","Teal","Thistle","Tomato","Turquoise","Violet","Wheat","White","WhiteSmoke","Yellow","YellowGreen" );
		var len = colors.length;
		var color = colors[Math.ceil(Math.random()*len)];
		return ((color == '') ? colors[Math.ceil(Math.random()*len)] : color);
	},
		//系统日期
	sysDate : function(fmt)
	{
		var cur_date = new Date();
		var cur_year = cur_date.getFullYear();
		var cur_month = cur_date.getMonth()+1;
		var cur_day = cur_date.getDate();
		if(fmt == 'Y')
		{
			return cur_year;
		}
		else if(fmt == 'M')
		{
			return cur_month;
		}
		else if(fmt == 'D')
		{
			return cur_day;
		}
		else if(fmt == 'L')	//本地化日期
		{
			return cur_date.toLocaleFormat("%Y-%m-%d %p %H:%M:%S %a");
		}
		else if(fmt != '')
		{
			return cur_year+fmt+cur_month+fmt+cur_day;
		}
		else
		{
			//return cur_year+'-'+cur_month+'-'+cur_day;
			return cur_date.toLocaleFormat("%Y-%m-%d");
		}
	},
		//系统时间方法2  见：P393   2015/12/27
	sysdate:function(fmt)
	{
		var d = new Date();
		var format = {"Y":d.getFullYear(),"M":d.getMonth()+1,"D":d.getDate(),"FD":d.toLocaleFormat("%Y-%m-%d"),"FT":d.toLocaleFormat("%Y-%m-%d %H:%M:%S"),"FC":d.toLocaleFormat("%Y-%m-%d %p %H:%M:%S %a")};
		if('undefined' == typeof(fmt)) fmt = 'FD';
		return format[fmt];
		
	},
		//获取当前时间	2016/4/14
	time: function(){return this.sysdate('FT')},
		//获取当前的日期	2016/5/10 星期二
	date: function(){return this.sysdate("FD");},
		//获取月末时间
	endMonth:function(date)
	{
		var d = '';
		if('undefined' == typeof(date))
		{
			var d = new Date();
		}
		else
		{	
			d = new Date(date);
		}
		var year = d.getFullYear(),month = d.getMonth()+1;
		var new_month = month+1;
		if(new_month > 12)
		{
			year +=1;
			month = '1';
		}
		else month +=1;
		if(month < 10) month = '0'+month;
		var day = year+'-'+month+'-01'
		return this.dateAdd(day,-1);
		
	},
		//生成数据显示表	2015/12/20
	/*
	 *	data  array数据（PHP后台数据），declare 表格声明，body 表格数据申明
	 *	body=Array("key1","key2","key3",子数组（Array,Arr）)  Arr = Array(null,"<HTML></HTML>") 添加单纯的HTML元素，Array("<HTML>","key","</HTML>"),
	 *
	 */
	makeTable(data,declare,body)
	{
		if(data == '') return;
		var html = declare;//<table><tr><th></th></tr>
		for(var v in data)
		{
			var xRow = ((parseInt(v)==0)? 1 : parseInt(v)+1);
			html += '<tr class="'+xRow+'"><td>'+xRow+'</td>';
			for(var k in body)
			{
				var tmp = body[k];
				if(typeof(tmp) == 'string') html += '<td>'+data[v][tmp]+'</td>';
				if(typeof(tmp) == 'object') 
				{
					if(body[k][0] == null) html += '<td>'+body[k][1]+'</td>';
					else
					{
						var tmp2 = body[k][1];
						html += '<td>'+body[k][0]+data[v][tmp2]+body[k][2]+'</td>';
					}
				}
			}
			html += '</tr>';
		}
		html += '</table>';
		return html;
	},
		//数字下拉框
	/*	2015/12/23
	 *	parameter：n = 宽度数，name = select 元素的name属性，selected = 默认值，order = ASC 升序，其他降序
	 *
	 */
	//numSelect: function(n,i=1,name=null,selected=null,order='ASC')		// 浏览器兼容性  修改 2016/1/24
	numSelect: function(n,i,name,selected,order)
	{
		i = (this.empty(i)? 1 : i);						//2016/1/24 @修改
		order = (this.empty(order)? 'ASC' : order);		//2016/1/24 @修改
		if(n == '') return;
		var selectName = ((name == '')? 'numSelect' : name);
		var select = '<select name="'+selectName+'">';
		if(order == 'ASC')
		{
			for(i;i<=n;i++)
			{
				select += ((i == selected)? '<option value="'+i+'" selected="selected">'+i+'</option>' : '<option value="'+i+'" >'+i+'</option>');
			}
		}
		else
		{
			for(n; n >= i; n--)
			{
				select += ((n == selected)? '<option value="'+n+'" selected="selected">'+n+'</option>' : '<option value="'+n+'" >'+n+'</option>');
			}
		}
		select += '</select>';
		return select;

	},
		//获取表单 元素的选中值
	getInputVal: function (name)
	{
		var val = '';
		val = $('select[name="'+name+'"] option:selected').val();	//select
		if(val == '' || typeof(val) == 'undefined')
		{ 
			var type = $('input[name="'+name+'"]').attr("type");
			val = $('input[name="'+name+'"]').val();	//input
			if(type == 'radio') val = $('input[name="'+name+'"]:checked').val();	//input :radio
		}
		return val;

	},
		//toJson serializeArray() 数组转json数据		2016/1/9
		//	替代getInputVal获取逐个表单数据
	toJson: function(array)
	{
		if(this.empty(array)) return;
		var json = {};
		for(var k in array){
			json[array[k]['name']] = array[k]['value'];
		}
		return json;
	},
		//2016/1/16		toJson 改进方法
		//select  选择器（表单选择器）
	formJson: function(select)
	{
		var arr = $(select).serializeArray();
		return this.toJson(arr);
	},
		//设置表单值
	setInputVal: function(name,value)
	{
		var val = '';
		val = $('select[name="'+name+'"] option:selected').val();	//select
		if(typeof(val) != 'undefined')
		{
			$('select[name="'+name+'"] option:selected').val(value);	//select
			//return val;
			return true;
		}
		var type = $('input[name="'+name+'"]').attr("type");
		if(type == 'radio')
		{
			$('input[name="'+name+'"] :checked').val(value);//input:radio
			return true;
		}
		$('input[name="'+name+'"]').val(value);//input
		return true;
	},
	/*	数据字段的唯一性判断		2016/1/17
	 *	table 数据表，where ={}条件
	 *
	 *
	unique:function(table,where,debug)
	{	//数据返回失败-bug =》 函数调用失败
		if(this.empty(table)) return null;
		if(this.empty(where)) return null;
		$.post(this.DOEE+'Function/unique',{model:table,where:where,debug:true,sid:Math.random()},
			function(data){
				//alert(data);
				return data;
				//if(this.empty(data)) return null;
				if(debug){
					if(data['result']>0) return true;
					return null;
				}
				return data;
		});
	},*/
	
		//<a href="javascript:void(0);" class="preview" id="preview:'+bud_no+'">
	/*
	 *		2016/1/3
	 *		多链接获取  元素id   a 元素格式：<a href="javascript:void(0);" class="Eclass" id="Eclass:id">text</a>
	 *
	 */
	getAidVal:function(id)
	{
		var tmpArr = id.split(":");
		return tmpArr[1];
	},
		//getAidVal  的扩展版	2016/5/16 星期一
	aid: function(dom,attrName)
	{
		var id = dom.attr(attrName);
		return this.getAidVal(id);
	},
		//生成 a 格式元素
	crtAidEle:function(Eclass,id,text)
	{
		if(this.empty(Eclass) || this.empty(text) || this.empty(id)) return;
		return '<a href="javascript:void(0);" class="'+Eclass+'" id="'+Eclass+':'+id+'">'+text+'</a>';
		
	},
		//非空提醒(input-普通表单) 2015/12/27
	/*
	 * select 选择器,name 元素名称-用户提醒,html 提醒方式默认 alter,
	 *
	 */
	isnullInput: function(select,name,tips,html)
	{
		var text = (this.empty(name)? '请检查必填项！' : '['+name+'] 不可为空');
		if(tips) text = tips;
		var val = $(select).val();
		if(this.empty(val))
		{
			if(this.empty(html)) alert(text);
			else $(html).html(text);
			$(select).focus();
			return true;
		}

	},
		//checked	表单 非空检测  =》 class		2016/1/27 星期三	实验性
	/*
		必填*：eleClass 表单类名，可选^:tip alert/html 提示，selfTip 自定义提醒语句，css 警示样式，oCss 表单原始样式
		表单命名规则应该：input:name=>element:desc=name-desc
	*/
	checked: function(eleClass,tip,selfTip,css,oCss)
	{
		if(this.empty(eleClass)){
			return;
			console.log("class 选择器不可为空！！");
		}
		if(this.empty(css)){
			css = {"border":"red solid 1px","background":"#99cccc"};
		}
		if(this.empty(oCss)){
			oCss = {"border":"black solid 1px","background":"white"};
		}
		var tmp = null;
		//var val = $("."+eleClass).each(function(index,element){
		var val = $("."+eleClass).each(function(){
			//tmp = element;
			var value = null;
			var name = $(this).attr("name");
			if($(this).is("select")){
				value = $(this).children("option:selected").val();
			//		~~~新语句~~~
			}else if($(this).attr("type") == "radio" || $(this).attr("type") == "checkbox"){
				vaule = $('input[name="'+name+'"]:checked').val();alert('input[name="'+name+'"]:checked');return;
			/*	//		2016/3/3  bug ~ roadi/checkbox 无效
			}else if($(this).attr("type") == "" || $(this).attr("type") == ""){
				vaule = $('input[name="'+name+'"] checked').val();
			*/
			}else{
				value = $(this).val();
			}
			if(value == '' || typeof(value) == "undefined" || value == null){
				tmp = true;
				$(this).css(css);
				$(this).focus();//alert('[desc="'+name+'-desc"]');return false;
				var desc = $('[desc="'+name+'-desc"]').text();
				var tipDesc = ((selfTip)? selfTip : '^'+desc+'^不可为空！');
				if(tip == "alert"){
					alert(tipDesc);
				}else if(tip){
					$(tip).html(tipDesc);
				}
				return false;
			}else{
				$(this).css(oCss);
			}
		});
		return tmp;
		//var callbacks = $.Callbacks();		//$.Callbacks()无法达到需要的效果
		//return callbacks.add(val);
	},
		//smp_check 简单 checked方法	2016/4/25
	/*
	 *	@ *check 检测， *data 数据库数据或者表单数据选择器
	 *	可选： tip  自定义提示文本  必须包含 $(tpl)
	 *	可选： xhtml  html提示列，并且具有参数正确性检测功能。扩展参数“2016/5/15 星期日”
	 *	返回: bool		
	 *	按表单的名称“name”属性为准
	 */
	smp_check: function(check,data,tip,xhtml)
	{
		if(this.empty(check)){
			console.log('请输入check参数！');
			return false;
		}
		var fEle = '[name="\'+k+\'"]';//聚焦元素
		if(typeof(data) != 'object'){
			fEle = '$("'+data+'").find('+fEle+').focus()';
			data = this.formJson(data);
		}
		if(this.empty(check)){
			console.log('无法获取到数据！');
			return false;
		}
		var tip_temp = this.empty(tip)? '请输入【tpl】' : tip;
		for(var k in check)
		{
			if(this.empty(data[k])){
				tip = tip_temp.replace(/tpl/g,check[k]);
				if(this.empty(xhtml) || $(xhtml).length == 0)
					alert(tip);
				else
					$(xhtml).html(tip);
				$('[name="'+k+'"]').focus();
				eval(fEle);
				return true;
			}
		}
	},
	/**
		数据更新，用于修改数据时赋值	2016/5/22 星期日
	**/
	update: function(data)
	{
		if(this.empty(data)) return false;
		for(var k in data)
		{
			$('[name="'+k+'"]').val(data[k]);
		}
	},
		//2016/5/16 星期一		数据修改检测
	modify: function(oldV,newV,strict)
	{
		if(this.empty(oldV) || this.empty(newV)) return false;//为空是检测不通过
		var is_modify = false;
		strict = this.empty(strict)? true : false;//默认为严格检测,忽略空格
		for(var k in oldV){
			if('undefined' != typeof(newV[k]) && (($.trim(oldV[k]) != $.trim(newV[k]) && strict) || (oldV[k] != newV[k] && !strict))){
			//if(this.empty(newV[k]) && oldV[k] != newV[k]){
				//return oldV[k]+'*'+newV[k];
				return true;//一旦有值发生变动则跳出检测
			}
		}
		return is_modify;
	},
		/*	2016/5/2  点击编辑后，根据键值设置表单的初始值
	     *	data{k:val,k2:val2}: val=>name[k]  【必填】
	     *	prefix: 前缀/命名空间
	     */
	edit: function(data,prefix)
	{
		if(this.empty(data)){console.log('参数值不可为空！');return;}
		for(var k in data)
		{
			if(this.empty(prefix)) $('[name="'+k+'"]').val(data[k]);
			else $(prefix).find('[name="'+k+'"]').val(data[k]);
		}
	},
	/*	获取 input 描述  -描述申明：element[_desc="name"]		2016/3/9
	 *	param@ *select 表单选择器（name为空时），name 元素名称，desc 描述选中器，自定义类型
	 *
	 *
	 */
	getDesc: function(select,name,desc)
	{
		if(this.empty(name)){
			if(H.empty(select)) return false;
			name = $(select).attr("name");
		}
		desc = (this.empty(desc)? '[_desc="'+name+'"]':desc);
		var text = $(desc).text();
		return text;
	},
		//判断变量为空		2015/12/31
	empty: function (value)
	{
		if('undefined' == typeof(value)) return true;
		else if('undefined' == value)	return true;
		else if(value == null) return true;
		else if(value.length == 0) return true;
		//else if(value == '') return true;//字符串为空时
		else if('object' == typeof(value) && this.json_len(value) == 0) return true;	//空接json数据,该条件不够健壮
		else return null;
	},
		//没有设置值	2016/4/8
	isset: function(value){if('undefined' == typeof(value)) return true;return false;},
	noset: function(value){return this.isset(value);},//isset 的别名
	//tableFrom 生成表格表单
	//tableFrom: function(declare,json,simple=null)	IE不支持
	/*	表单名称唯一性
	 *	declare table标题;json={"name":"type","name":{select或者input},...}}},  
	 当为特殊表单数条用自己的函name:{"element":"select","name":"nameVal","selected":"value","option":{"value":"text",...}}或{"element":"input","type":"typeVal","name":"nameVal","checked":"value",val:{"value":"text",...}}
	 *	简单全文本框 json = new Array("name1","name2",...);
	 */
	tableFrom: function(declare,json,simple)	//兼容IE
	{
		simple = (('undefined' == typeof(simple))? ' ':simple);
		var html = declare;
		html += '<tr>';
		if(('undefined' == typeof(json)) || (json.length == 0)) return;
		if('undefined' == typeof(json['name']))
		{
			var len = json.length;
			for(var i=0; i<len; i++)
			{
				html += '<td><input type="text" name="'+json[i]+'"></td>';
			}
		}
		else
		{
			for(var p in json)
			{
				if('object' == typeof(json[p]))
				{
					html += '<td>'+this.specialFrom(json[p],simple)+'</td>';
				}
				else
				{
					var type = ((json[p] == '')? 'text' : json[p]);
					html += '<td><input type="'+type+'" name="'+p+'"></td>';
				}
			}
		}
		html += '</tr></table>'
		return html;
	},
		//生成单选/复原/下拉框等
	/*
	 *	elem = {"element":"select","name":"nameVal","selected":"value","option":{"value":"text",...}}或{"element":"input","type":"typeVal","name":"nameVal","checked":"value",val:{"value":"text",...}}
	 *
	 */
	specialFrom: function(elem,gap)
	{
		gap = (('undefined' == typeof(gap))? ' ':gap);
		var html = '';
		if(elem['element'] == 'select')
		{
			html += '<select name="'+elem['name']+'">';
			for(var v in elem['option'])
			{
				html += ((v == elem['select'])? '<option value="'+v+'" selected="selected">'+elem['option'][v]+'</option>':'<option value="'+v+'">'+elem['option'][v]+'</option>');
			}
			html += '</select>';
		}
		if(elem['element'] == 'input')
		{
			var type = ((elem['type'] == '')? 'radio':elem['type']);
			for(var v in elem['val'])
			{
				html += ((v == elem['checked'])? '<input type="'+type+'" name="'+elem['name']+'" checked>':'<input type="'+type+'" name="'+elem['name']+'">');
				html += elem['val'][v]+gap;
			}
		}
		return html;
	},
	/*	自定义搜索（2016/3/20）
	 *	param@ colParam={"colName":"colDescript",...}
	 *	param@ equation={"equation":"Descript",...}
	 *	param@ order={"equation":"Descript",...}  排序
	 *	
	*/
	customSear: function(colParam,equation,order)
	{
		if(this.empty(colParam)) return '<p style="color:red;font-size:1.5em">@：列参数不可为空</p>';
		if(this.empty(equation)){
			equation = {"like":"包含","eq":"等于","notlike":"不等于"};//eq 参考ThinkPHP3.2.3 P147 $map['id'] = array('eq',100);
		}
		var xhtml = '';
		xhtml = '<p id="customBar">列名:';
		var elem = {"element":"select","name":"customCols","option":colParam};//elem = {"element":"select","name":"nameVal","selected":"value","option":{"value":"text",...}}或
		xhtml += this.specialFrom(elem);
		var elem2 = {"element":"select","name":"customEqua","option":equation};// 运算关系符
		xhtml += this.specialFrom(elem2);
		var or_xhtml = '';//排序
		if(typeof(order) == 'object' && !isNaN(this.json_len(order)) && this.json_len(order) > 0){
			var elem3 = {"element":"select","name":"customOrder","option":order};// 可选排序
			or_xhtml = '排序'+this.specialFrom(elem3)+' <input type="checkbox" name="customOrType" value="DESC" title="逆序，默认为顺序">';
		}
		xhtml += '<span id="customIpt"><input type="text" name="customIpt"></span>'+or_xhtml+'<button type="button" id="cstmSearBtn">确定</button></p>';
		return xhtml;
	},
		//文件后缀和文件名			返回文件：文件名，文件类型，两者
	//	必填：filename 文件名字，可选： type 类型	suffix(S) 文件后缀,preffix(P) 文件名
	fileInfo: function(filename,type)
	{
		if(this.empty(filename)) return false;
		var tmpArr = filename.split('.');
		//var len = tmpArr.length;
		if(type == 'S'){
			//return tmpArr[len-1];
			return tmpArr.pop();
		} else if(type == 'P'){
			tmpArr.pop();
			return tmpArr.join(".");
		}else{
			var Img = {};
			Img["S"] = tmpArr.pop();
			Img["P"] = tmpArr.join(".");
			return Img;
		}
	},
		//JS 加载器	2016/1/21		filname: 文件名(*.js中的-*-)
	load: function(filename,dir)
	{
		if(this.empty(filename)) return false;
		else if(this.empty(dir)){
			$("head").append('<script src="/Doeeking/Public/JS/Load/'+filename+'.js"></script>');
			return true;
		}
		else{
			$("head").append('<script src="/Doeeking/Public/'+dir+filename+'.js"></script>');//JS 文件夹
			return true;
		}
	},
	//H.load("encrypt","library/");//-加载	library/encrypt.js
	library: function(filename)
	{
		this.load(filename,"JS/library/");//-加载	library/encrypt.js
	},
		// 2016/1/24		显示-隐藏转换		参数:show String/Array显示选择器，hide String/Array 隐藏选择器,debug 调试返回
	Transition(show,hide,debug)
	{
		var html  = '';
		if(typeof(show) == "string"){
			$(show).show();
			html  += '$('+show+').show();\n';
		}
		else{ 
			for(var k in show) 
			{
				$(show[k]).show();
				html  += '$('+show[k]+').show();\n';
			}
		}
		if(typeof(hide) == "object")
		{
			for(var kk in hide) 
			{
				$(hide[kk]).hide();
				html  += '$('+hide[kk]+').hide();\n';
			}
		}	
		else{
			$(hide).hide();
			html  += '$('+hide+').hide();\n';
		}
		if(!this.empty(debug))
			return html;
	}, 
		//	2016/2/15			获取js 版 用户信息
	infoUser: function(name)
	{
		var infoUser = this.getStorage("infoUser");
		if(this.empty(infoUser))
			return "您还没有登入系统！！";
		var json = $.parseJSON(infoUser);
		if(this.empty(name))
			return json;
		if(json[name])
			return json[name];
		return json;
	},
		//	2016/2/21	利用JqueryUI生成dialog，可选参数：xhtml 弹窗元素；id 自定义dialog元素id属性；dialog [默认]弹出对话框，true 仅仅用于动态生成div
	dialog: function(xhtml,id,title,dialog)
	{
		//if(this.empty(xhtml)) return;
		if(this.empty(xhtml)) xhtml = '';
		id = (this.empty(id)? "dialog" : id);
		title = (this.empty(title)? "请稍后，程序正在运行……" : title);
		if($("#"+id).length>0){	//不重复生成元素
			$("#"+id).html(xhtml);
		}else{
			var chtml = '<div id="'+id+'" sign="getDialog" style="display:none">'+xhtml+'</div>';
			$("body").append(chtml);
		}
		if(this.empty(dialog)){ //	默认作为弹出框
			$("#"+id).dialog({modal:true,title:title});
		}
	},
	/*	2016/2/28	
	 *	将：array/json转为json字符串	
	 *  进行递归调用
	*/
	toString:function(json)
	{
		if(this.empty(json))
			return;
		var str = '';
		var strArr = new Array();
		var val = '';//undefined 数据清除避免对$.parseJSON函数的干扰,测试结果不奏效
		for(var k in json)
		{
			if('object' == typeof(json[k])){
				strArr.push('"'+k+'":'+this.toString(json[k]));//递归调用
			}else{
				val = this.empty(json[k])? '' : json[k];
				strArr.push('"'+k+'":"'+val+'"');
			}
		}
		return '{'+strArr.join(",")+'}';
	},
		//	2016/4/11 jquery 强化版(实验性扩展)
	/*
	 *	parseJSON
	 *2016/5/16 星期一部分地方引用
	 */
	parseJSON: function(jsonStr)
	{
		if(this.noset(jsonStr)) return false;
		var save = {'undefined':'""','&nbsp;':' '};
		for(var k in save)
		{
			eval('jsonStr = jsonStr.replace(/'+k+'/g,save[k])');
		}
		//return jsonStr;
		return $.parseJSON(jsonStr);
	},
		//获取本地页面存储信息	2016/2/28
		//	参数：*page 页面名字，name 页面属性名字
		//	返回：array/string/null
	getPStor: function (page,name,debug)
	{
		if(this.empty(page))
			return;
		var jsonStr = this.getStorage(page);
		if(!this.empty(debug)) return jsonStr;
		if(this.empty(jsonStr))	//页面没有 本地存储信息
			return jsonStr;
		var json = $.parseJSON(jsonStr);	 
		if(this.empty(json[name]))	//没有指定的页面下元素信息 则放回整个 json 的值
			return json;
		return json[name];
	},
		//设置本地页面存储信息	2016/2/28
	setPStor: function(page,name,value)
	{
		if(this.empty(page)) return;
		if(this.empty(name)) return;
		if(this.empty(value)) return;
		var tmp = this.getPStor(page);
		//console.log(tmp);
		if(this.empty(tmp)){
			var json = {};
			json[name] = value;
			this.setStorage(page,this.toString(json));
			return true;
		}
		else if(this.empty(tmp[name])){
			tmp[name] = value;
			this.setStorage(page,this.toString(tmp));
			return true;
		}
		else if(!this.empty(tmp[name])){
			tmp[name] = value;
			this.setStorage(page,this.toString(tmp));
			return true;
		}
		return false;
	},
	/*
		//	2016/2/21	参数：*table 数据表，*where  条件。可选参数：field 统计字段
	inData:function(select,table,where,field)
	{
		var isright = false;
		var url = this.DOEE+'Function/inData';
		var json = {};
		json['model'] = table;
		json['where'] = where;
		json['uid'] = Math.random();
		if(!this.empty(field))
			json['count'] = field;
		$.post(url,json,function(data){
			if(data){
				alert(data);
				isright = true;
			}
		});
		//return isright;
	},
	*/
		//	2016/2/21 关闭-dialog
	closeDialog: function()
	{
		var id = $('div[sign="getDialog"]').attr("id");
		if(this.empty(id))
			return;
		$("#"+id).dialog("close");
	},
		//--------------------storage
	//_storageAvailable	私有方法：环境storage检测
	_storageAvailable: function (type)
	{
		try {
			var storage = window[type],
				x = '__storage_test__';
			storage.setItem(x, x);
			storage.removeItem(x);
			return true;
		}
		catch(e) {
			return false;
		}
	},
		//设置	localStorage
	setStorage:function (loName,loVal)
	{
		if(this.empty(loName)) return false;
		if(this._storageAvailable("localStorage"))
		{
			var lo = window.localStorage;
			var tmp = lo.getItem(loName);
			if(tmp){
				lo.removeItem(loName);
				lo.setItem(loName,loVal);
			}else{
				lo.setItem(loName,loVal);
			}
		}else{
			return "您的浏览器不支持localStorage！！";
		}
	},
		//获取	localStorage
	getStorage: function (loName)
	{
		if(this._storageAvailable("localStorage"))
		{
			var lo = window.localStorage;
			try {
				var tmp = lo.getItem(loName);
				return tmp;
			}catch(e) {
				return false;
			}
		}else{
			return "您的浏览器不支持localStorage！！";
		}
	},
		//移除	localStorage
	delStorage: function(loName)
	{
		if(this._storageAvailable("localStorage"))
		{
			var lo = window.localStorage;
			try {
				var tmp = lo.getItem(loName);
				lo.removeItem(loName);
				return true;
			}catch(e) {
				return false;
			}
		}else{
			return "您的浏览器不支持localStorage！！";
		}
	},
		//sessionStorage 会话存储，关闭网页后自动清除
	session: function(name,value)
	{
		if(this.empty(name)) return null;
		/* //方式 1
		//if(this.empty(value))	return sessionStorage[name];	//获取sessionStorage
		if(this.isset(value))	return sessionStorage[name];	//获取sessionStorage
		sessionStorage[name] = value;		//设置sessionStorage
		*/
			//方式2	2016/4/8
		if(this.isset(value))	return sessionStorage.getItem(name);
		sessionStorage.setItem(name,value);
		return true;
	},
		//loaclstroge 本地存储	2016/4/8
	local: function(name,value)
	{
		if(this.isset(name)) return false;
		if(this.isset(value)) return this.getStorage(name);
		this.setStorage(name,value);
	},
		//采用 sessionStorage 设置显示界面，使刷新后依然菜单不变		2016/3/26
	/*
	 *	参数：register 各菜单之间采用逗号分隔 m1,m2,m3,m.. (菜单选择器)，cMenu 为设置的当前菜单
	 *  Mname，rName 用于类菜单体扩展
	 *	sessionStorage:不是页面独立，而是整个浏览器都存在，类似PHP的session
	 */
	menu: function(cMenu,register,Mname,rName,debug)
	{
		Mname = (this.empty(Mname)? 'sMenu' : Mname);							//	菜单显示“存储名”
		rName = (this.empty(rName)? 'mRegi' : rName);							//	菜单注册“存储名”

		register = (this.empty(register)? this.session(rName) : register);		// 获取注册的所有“菜单”
		if(this.empty(register)) return;
		if(!this.empty(cMenu)) this.session(Mname,cMenu);						// cMenu 非空是设置
		if(this.empty(this.session(rName)) && !this.empty(register))			// 设置注册的所有“菜单”
			this.session(rName,register);
		var menu = this.session(Mname);
		var registerArr = register.split(",");
		if(this.empty(menu)){//为空时，去register的第一个为显示菜单
			this.session(Mname,registerArr[0]);
			menu = registerArr[0];
		}
		var hide = this.unset(registerArr,menu);								//采用逗号分隔菜单
		if(!this.empty(debug)){
			var dJson = {};//debugJson
			dJson["param"] = new Array(cMenu,register,debug,Mname,rName);
			dJson["menuSession"] = {};
			dJson["menuSession"][Mname] = this.session(Mname);
			dJson["menuSession"][rName] = this.session(rName);
			dJson["Transition"] = '“menu”调试输出：  '+this.Transition(menu,hide,true);
			dJson["tParam"] = {menu:menu,hide:hide};
			console.log(dJson);
		}
		this.Transition(menu,hide);
	},
		// 删除数组(Array,非json)中元素2016/3/26 
	/*
	 *	必填：arr,val;arr 数组，val 可以是数组的‘键’也可是‘值’
	 *
	 */
	unset: function(arr,val)
	{
		var nArr = new Array();
		var len = arr.length;
		if(this.empty(arr)) return false;
		if(this.empty(val)) return false;
		if(!this.empty(arr[val])){//键值
			arr.splice(val,1);
			return arr;
		}
		if(typeof(val) == 'string'){
			if(val == arr[0]){
				arr.shift();
				return arr;
			}
			else if(val == arr[len-1]){
				arr.pop();
				return arr;
			}
			else{
				for(var k in arr){
					if(arr[k] != val){nArr.push(arr[k]);}
				}
			}
		}
		return nArr;
	},
		//删除json数据中指定的key或者val2016/5/12 星期四		局限于普通的key-value json数据
		/*
		  *		+val 键/值,+json 
		  *		优先考虑键
		  *
		*/
	json_pop: function(val,json)
	{
		if(this.empty(val)) return "要删除的值不可为空";
		if(this.empty(json)) return "要删除的json不可为空";
		//为键值时
		var new_json = {};
		if(!this.empty(json[val])){
			for(var k in json){
				if(k != val) new_json[k] = json[k];
			}
		}
		else{
			for(var k in json)
			{
				if(json[k] != val)	new_json[k] = json[k];
			}
		}
		var len = this.json_len(new_json);
		if(len == 0 || len == '0') new_json = json;
		return new_json;
	},
		//json数据过滤器  2016/5/16 星期一  
	/**
		参数：   filter 可为单个  key/或多key Array(只接受数组)  json 原来的json数据
		返回：   new json，过滤后的json
	**/
	json_filter: function(filter,json)
	{
		if(typeof(json) == 'object' && ! $.isArray(json)){
			if($.isArray(filter)){
				var v = '';
				for(var k in filter){
					v = filter[k];
					delete json[v];
				}
			}else if(typeof(filter) != 'object' && typeof(json[filter]) != 'undefined'){
				delete json[filter];//参考网上说法
			}
			return json;
		}
	},
		//跳转到首页	2016/3/27
	home:function(){location.href="/Doeeking";},
		// 全选与取全选	2016/3/27  *actSel 操作选择器，*els 元素集选择器
	selected: function(actSel,els)
	{
		if(this.empty(actSel)) return;
		if(this.empty(els)) return;
		var check = $(actSel+':checked').val();
		if(this.empty(check)){$(els).prop("checked",false);}
		else{$(els).prop("checked",true);}
	},
		// 获取复选框值	2016/3/27
	getSelVal:function(sels)
	{
		if(this.empty(sels)) return;
		var valArr = [];
		$(sels+':checked').each(function(){valArr.push($(this).val());});
		return valArr;
	},
		//beforeColse 关闭窗口前触发事件	2016/4/10 接口
	beforeColse: function()
	{
		window.onbeforeunload = function(event){return this.beforeColse();};
		return true;
	},
		//jQuery Ajax 发送 post 数据，避免重复书写 uid:Math.random()
	ajaxPost: function(json)
	{
		if(typeof(json) != 'object') return null;
		json['uid'] = Math.random();
		return json;
	},
		//selectData PHP的前台支持，将条件转为js  mysql 版本
	selectData: function(table,filter,where,other)
	{
		if(this.empty(table)) return false;
		filter = this.empty(filter)? '*' : filter;
		var sql = 'select '+filter+' from '+table;
		if(!this.empty(where)){
			var tmpArr = new Array();
			for(var k in where)
			{
				tmpArr.push(k+'="'+where[k]+'"');
			}
			sql += ' where '+tmpArr.join('and');
		}
		if(!this.empty(other)) sql += ' '+other;
		return this.ajaxPost({"model":table,"sql":sql});
	},
	/**
		sel_filter PHP的前台函数支持  selectId	2016/5/22 星期日
		*table(数据表),*where,*feek(函数)
		filter 可选格式-string,array,null
	**/
	sel_filter: function(table,filter,where,feek)
	{
		if(this.empty(table) || this.empty(where)){this.log('sel_filter 函数的model,where,feek(函数)必填');return null;}
		if(!this.is_fn(feek)) {this.log('sel_filter 函数参数feek(函数)必填，且只能为函数');return null;}
		$.post(this.DOEE+"Function/sel_filter",this.ajaxPost({'model':table,'where':where,'filter':filter}),feek);
	},
	/**
	**/
	use_tpl: function(name,id,use)
	{
		if(this.is_fn(use)) feek = use;
		else
			var feek = function(data){$(use).html(data)}
		$.post(this.DOEE+"Function/use_tpl",this.ajaxPost({'name':name,'id':id}),feek);
	},
		//是否为函数	2016/5/22 星期日
	is_fn: function(fn)
	{
		if(typeof(fn) == 'function') return true;
		return false;
	},
		//获取数据操作模式~类似公司管家概念2016/4/13
	mode: function(sel)
	{
		sel = this.empty(sel)? '#dataMode' : sel;
		return $(sel).val();
	},
		//通用表单数据 格式	2016/4/13
	/*
	 *	option{"form":"val","mode":"val","table":"val"}'设置参数初始值';
	 *	xhtml : dataSelect 数据选择器,dataVessel 数据容器,dataMode 数据操作模式 。一相当于：form选择器,表名,模式
	 *	
	 */
	formInit: function(view,option)
	{
		option = (this.noset(option) || typeof(option) != 'object')? {} : option;
		var form = this.empty(option['form'])? '': option['form'];
		var table = this.empty(option['table'])? '': option['table'];
		var pkey = this.empty(option['pkey'])? '': option['pkey'];
		var mode = this.empty(option['mode'])? '': option['mode'];
		var xhtml = '<input type="hidden" id="dataSelect" value="'+form+'"><input type="hidden" id="dataVessel" value="'+table+'"><input type="hidden" id="dataKey" value="'+pkey+'"><input type="hidden" id="dataMode" value="'+mode+'">';
		if(this.empty(view)) return xhtml;
		else $(view).html(xhtml);
	},
		//设置formParam 表单参数 2016/4/13	
	formParam: function(json)
	{
		if(this.noset(json) || typeof(json) != 'object') return false;
		if(!this.empty(json['form'])) $('#dataSelect').val(json['form']);
		if(!this.empty(json['table'])) $('#dataVessel').val(json['table']);
		if(!this.empty(json['pkey'])) $('#dataKey').val(json['pkey']);
		if(!this.empty(json['mode'])) $('#dataMode').val(json['mode']);
	},
		//获取fromInit定制生成的表单数据	2016/4/13
	formData: function()
	{
		var formData = {};
		var sel = $('#dataSelect').val();
		formData['data'] = this.formJson('#'+sel);
		formData['table'] = $('#dataVessel').val();
		formData['mode'] = this.mode();
		if('A' != this.mode())	formData['pkey'] = $('#dataKey').val();
		return this.ajaxPost(formData);
	},
		// 获取fromData的参数	2016/4/13
	getForm: function(name)
	{
		var fromData = this.formData();
		if(this.empty(name)) return fromData;//非空时是formData()函数的别名
		return fromData[name];
	},
		//form_tip 提示格式设置	2016/5/9 星期一
	/*
		*sel  单个表单选择器，tip 提示内容， alert  默认提示方式，否则提示XHTML
	*/
	form_tip: function(sel,tip,alert)
	{
		if(this.empty(sel)){return true};
		if(this.empty(tip)){return true};
		if(this.empty(alert)){
			alert(tip);
		}else{
			$(alert).html(tip);
		}
		$(sel).val('');
		$(sel).focus();
		return true;
	},
		/*
		2016/5/10 星期二
		console.log 兼容性改进，在省交易中心官网测试发现在console.log 的情况下造成部分浏览器如(IE9-8-7)等兼容性存在问题  
		问题之一：无法准确的计算console.log的实际执行行
		或者调用console后应该及时清理
		*/
	log: function(val)
	{
		var con = window.console;
		if(this.empty(con)){
			return '您的浏览器不支持console！！';
		}
		console.log(val);
	},
		//json 的length  2016/5/10 星期二     json无length属性
	json_len: function(json)
	{
		if(typeof(json) == 'object'){
			var len = json.length;
			if(isNaN(len)){
				len = 0;
				for(var k in json) len += 1;
				//len -= 1;
			}
			return len;
		}
		//return "输入的变量不属于json类型";
		this.log("json_len函数输入的参数不属于json类型");
		return false;
	},
		//数组最大与最小值计算
	arr_math: function(arr,type)
	{
		type = this.empty(type)? '': type;//默认为最大值
		if(typeof(arr) == 'object'){
			var retVal = 0;
			if(type == 'min'){
				var asc = function(a,b){return a-b;};
				arr = arr.sort(asc);
				retVal = arr[0];
			}else if(type == 'avg'){//average
				retVal = this.arr_math(arr,'sum')/parseFloat(this.json_len(arr));
			}else if(type == 'sum'){
				for(var k in arr)	retVal += parseFloat(arr[k]);
			}else{
				var desc = function(a,b){return b-a;};
				arr = arr.sort(desc);
				retVal = arr[0];
			}
			return retVal;
		}
		return false;
	},
	/***********数组/JSON运算  2016/5/16 星期一***********/
		//数组并集  若arr1于arr2数据键同值不同则按照arr为依照   arr1=> arr2 =>arr1(返回) 前者映射到后者  单极
		//	数学中的   A 'U' B = 'AB'
	array_merge: function(arr1,arr2)
	{
		if(typeof(arr1) != 'object' || typeof(arr2) != 'object') return false;
		for(var k in arr2){
			if($.isArray(arr1)) arr1.push(arr2[k]);
			else	arr1[k] = arr2[k];//用1的只覆盖2,但是返回1的格式，即1位json二2为[]时返回[]
		}
		return arr1;
	},
		//数组交集 arr1=> arr2 =>arr1(返回)  建议arr两个值的属性同array或json
		//	数学中的   A 'n' B
	array_intersect: function(arr1,arr2)
	{
		if(typeof(arr1) != 'object' || typeof(arr2) != 'object') return false;
		var new_arr = [],key='';
		if($.isArray(arr1) && $.isArray(arr2)){//1[] => 2[]
			for(var k in arr1){
				key = arr2.indexOf(arr1[k]);
				if(key>-1)	new_arr.push(arr1[k]);
			}
		}else{
			new_arr = {};
			for(var k in arr1){
				if(arr1[k] == arr2[k]) new_arr[k] = arr1[k];
			}
		}
		return new_arr;
	},
		//数组差集   arr1差arr2=> A-B
	array_diff: function(arr1,arr2)
	{
		if(typeof(arr1) != 'object' || typeof(arr2) != 'object') return false;
		var new_arr = [],key = '';
		if($.isArray(arr1) && $.isArray(arr2)){//1-2 []
			for(var k in arr1){
				key = arr2.indexOf(arr1[k]);
				if(key == -1)	new_arr.push(arr1[k]);
			}
		}else{//1-2	{}
			new_arr = {};
			for(var k in arr1){// 根据键值判断
				if('undefined' == typeof(arr2[k])) new_arr[k] = arr1[k];
			}
		}
		return new_arr;
	},
		//表单锁定也解绑	2016/5/21 星期六
	lock: function(sel,type)
	{
		if(this.empty(sel)) return false;
		if($(sel).length == 0){this.log('选择器没有找到原始');return false};
		type = this.empty(type)? 'Y' : 'N';//默认为加锁
		if(type == 'Y') $(sel).attr('disabled','disabled');
		else if(type == 'N') $(sel).removeAttr('disabled');
		return true;
	},
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
//_____________________网上应用js程序

		//dateAdd	应用网上函数
	
	//dateAdd:function(date,number,interval='d') 
	dateAdd:function(date,number,interval) //兼容IE
	{ 
		interval = (('undefined' == typeof(interval))? 'd' : interval);
		var d = new Date(date); 
		var k={'y':'FullYear', 'q':'Month', 'm':'Month', 'w':'Date', 'd':'Date', 'h':'Hours', 'n':'Minutes', 's':'Seconds', 'ms':'MilliSeconds'}; 
		var n={'q':3, 'w':7}; 
		eval('d.set'+k[interval]+'(d.get'+k[interval]+'()+'+((n[interval]||1)*number)+')'); 
		return d.toLocaleFormat("%Y-%m-%d"); 
	} ,
		//datediff
	//dateDiff:function(objDate1,objDate2,interval='d')			?? 2015-10-1  造成错误：正解 2015-10-01
	dateDiff:function(objDate1,date2,interval) //兼容 IE
	{ 
		objDate2 = new Date(date2);
		interval = (('undefined' == typeof(interval))? 'd' : interval);
		var d=new Date(objDate1), i={}, t=d.getTime(), t2=objDate2.getTime(); 
		i['y']=objDate2.getFullYear()-d.getFullYear(); 
		i['q']=i['y']*4+Math.floor(objDate2.getMonth()/4)-Math.floor(d.getMonth()/4); 
		i['m']=i['y']*12+objDate2.getMonth()-d.getMonth(); 
		i['ms']=objDate2.getTime()-d.getTime(); 
		i['w']=Math.floor((t2+345600000)/(604800000))-Math.floor((t+345600000)/(604800000)); 
		i['d']=Math.floor(t2/86400000)-Math.floor(t/86400000); 
		i['h']=Math.floor(t2/3600000)-Math.floor(t/3600000); 
		i['n']=Math.floor(t2/60000)-Math.floor(t/60000); 
		i['s']=Math.floor(t2/1000)-Math.floor(t/1000); 
		return i[interval]; 
	},
/*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
		//其他对象
	/*
	 *	2015/11/29
	 *	元素不可为空
	 *	element 元素如#id（选择器），name-警告框名字，color显示颜色,ale(alert警告)，非空警告
	 */
	isNull: function(element,name,color,tip)
	{
		var showCol = (color == '')? '#3300ff' : color;
		$(element).css("background",showCol);
		var val = $(element).val();
		if(tip == 'out_blur')
		{
			if(val == '')
			{
				if(tip == '')	alert(name+'不能为空！请重新填写!');
				else	$(tip).html(name+'不能为空！请重新填写!');
				 $(element).val('');
				 $(element).focus();
				 return false;
			}
			return true;
		}
		$(element).blur(function(){
			if(val == '')
			{
				if(tip == '')	alert(name+'不能为空！请重新填写!');
				else	$(tip).html(name+'不能为空！请重新填写!');
				 $(element).val('');
				 $(element).focus();
				 return false;
			}
			return true;
		});
	},
	//数字
	isNumber: function (element,name,color,tip)
	{
		var showCol = (color == '')? '#3300ff' : color;
		$(element).css("background",showCol);
		$(element).blur(function(){
			var val = $(element).val();
			if(isNaN(val))			//非数字
			{
				if(tip == '')	alert(name+'输入的格式不正确，请输入数字!');
				else	$(tip).html(name+'输入的格式不正确，请输入数字!');
				$(element).val('');
				$(element).focus();
				return false;
			}
			return true;
		});
	},
	//日期格式
	isDate:function(element,name,color,tip)
	{
		var showCol = (color == '')? '#3300ff' : color;
		$(element).css("background",showCol);
		$(element).blur(function(){
			var val = $(element).val();
			var patrn =/^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})$/;//空格
			//var patrn2 =/^([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})$/;//空格
			//var patrn3 =/^([0-9]{4}).([0-9]{1,2}).([0-9]{1,2})$/;//空格
			//if(!patrn.test(use_date) && !patrn2.test(use_date) && !patrn3.test(use_date))
			if(!patrn.test(use_date))
			{
				$(element).val('');
				if(tip == '')	alert(name+'输入的格式不正确，请输入正确的日期格式!');
				else	$(tip).html(name+'输入的格式不正确，请输入正确的日期格式!');
				return false;
			}
			return true;
		});
	},
		//is_date,isDate的大范围
	is_date: function(val)
	{
		var undate = false;
		var patrn =/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/;//空格  2016-05-09
		if(patrn.test(val)) undate = true;
		return undate;
	},
		//是否仅仅又字母或者数字,下划线-（用户注册）
	isCode: function(value,minLen,maxLen)
	{
		if(this.empty(value)) return;
		minLen = (this.empty(minLen)? 3:minLen);
		maxLen = (this.empty(maxLen)? 50:maxLen);
		var patrn =/^[a-zA-Z0-9_-]{3,50}$/;//空格
		if(patrn.test(value)) return true;
		return false;
	},
		//是否为手机号	rewrite 重新正则表达式
	isCell: function(value,rewrite)
	{
		if(this.empty(value)) return;
		var patrn = (this.empty(rewrite)? /^[0-9]{11}$/ : rewrite);
		if(patrn.test(value)) return true;
		return false;
	},
		//是否是邮箱
	isEmail: function(value,rewrite)
	{
		if(this.empty(value)) return;
		var patrn =/^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/;
		if(!this.empty(rewrite)) patrn = rewrite;
		if(patrn.test(value)) return true;
		return false;
	},
	//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>2016/1/26 星期二		浏览器相关方法
	browser : function()
	{//Navigator 对象包含有关浏览器的信息。
		var infor = {};
		var userAgent = navigator.userAgent;
		var isOpera = userAgent.indexOf("Opera") > -1;
		if(isOpera)	infor["type"] = "Opera";
		if (userAgent.indexOf("Firefox") > -1){
			infor["type"] = "Firefox";
		}
		if (userAgent.indexOf("Chrome") > -1)	infor["type"] = "Chrome";
		if (userAgent.indexOf("Safari") > -1)	infor["type"] = "Safari";
		if (userAgent.indexOf("Edge") > -1)		infor["type"] = "Edge";
		//IE内核	ActiveXObject
		/*
		Microsoft Edge
		1.据 悉，Microsoft Edge 浏览器将不再支持 ActiveX、MIME、源剪辑 (WebSlices) 、 Vector Markup Language（VML）、浏览器帮助者对象 BHO（Browser Helper Objects） 和 VBScript。不过，对微软及开发者来说，取消这些技术也是利好消息，这样可免除这些技术带来安全漏洞。
		HTML5 :IE9+,Chrome25+,Firefox19+ 
		*/
		if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera){
			infor["type"] = "IE";
			var tmpk = parseInt(userAgent.indexOf("MSIE"))+5;
			infor["msie"] = userAgent.substr(tmpk,3);
		}
		if(this.empty(infor["type"] )){
			infor["type"] = "IE";
		}
		infor["name"] = userAgent;
		return infor;
	},
		//2016/1/26 星期二	web调用照相机
	camera: function(select)
	{
		/*
		navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
		if(navigator.getUserMedia){ // 标准的API
			navigator.getUserMedia({ "video": true }, function (stream) {
				video.src = stream;
				video.play();
			}, this.errCamera);
		}else if(navigator.webkitGetUserMedia){ // WebKit 核心的API
		navigator.webkitGetUserMedia({ "video": true }, function (stream) {
				video.src = window.webkitURL.createObjectURL(stream);
				video.play();
		}, this.errCamera);
		}
		*/
		//https://developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia
		if(this.empty(select)){
			select = 'video';
			$("body").append("<video></video>");
		}
		navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
		if (navigator.getUserMedia) {
		   navigator.getUserMedia({ audio: true, video: { width: 1280, height: 720 } },
			  function(stream) {
				 var video = document.querySelector(select);
				 video.src = window.URL.createObjectURL(stream);
				 video.onloadedmetadata = function(e) {
				   video.play();
				 };
			  },
			  function(err) {
				 console.log("The following error occurred: " + err.name);
			  }
		   );
		} else {
		   console.log("getUserMedia not supported");
		}
	}
};
window.H=Hyang;
